package com.share.exception;

import com.share.bean.vo.ResponseMsg;
import com.share.constant.SysErrorEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * author:caifan
 * date:2019/11/14
 */
@RestControllerAdvice
@Log4j2
public class ShiroExceptionHandler {

    @ExceptionHandler(value = LoginException.class)
    public ResponseEntity<ResponseMsg> getLoginException(SysErrorEnum errorEnum) {
        return new ResponseEntity<>(new ResponseMsg(errorEnum.getCode(), errorEnum.getMsg()), HttpStatus.UNAUTHORIZED);
    }
}
